<template>
  <div class="hello">
    <slot>默认内容</slot>
    <slot name="header"></slot>
    <h1>{{ msg }}</h1>
    <p>prop中的count是：{{ count }}</p>
    <button @click="handler">按钮</button>
    <slot name="footer" :childCount="childCount">footer的默认内容</slot>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  //组件通信
  //1.父传子：通过props进行处理
  //2.子传父：通过自定义事件处理
  props: {
    msg: String,
    count: {
      type:[String,Number],
      //表示这个参数可传可不传
      // default:100,
      //表示必须传值
      // required:true
    }
  },
  data(){
    return{
      childCount:0
    }
  },
  methods:{
    handler(){
      this.childCount++;
      this.$emit('child-count-change',this.childCount)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.hello{
  background-color: #7c8b85;
}
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
